package edu.nf.ssm.web;

import edu.nf.ssm.web.vo.ResultVO;
import org.springframework.http.HttpStatus;

/**
 * @ Author bin
 * @ Create  2025/5/13 上午9:30
 **/
public class BaseController {
    protected <T> ResultVO<T> success(T data){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(HttpStatus.OK.value());
        resultVO.setData(data);
        return resultVO;
    }

    /*
    * 仅响应成功
    * */
    protected <T> ResultVO<T> success(){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(HttpStatus.OK.value());
        return resultVO;
    }
    /*
    * 响应错误消息
    * */
    protected <T> ResultVO<T> error(Integer code,String message){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setCode(code);
        resultVO.setMessage(message);
        return resultVO;
    }
}
